<?php
/*********************/
/*                   */
/*  Version : 5.1.0  */
/*  Author  : RM     */
/*  Comment : 071223 */
/*                   */
/*********************/

define( "JIEQI_MODULE_NAME", "system" );
require_once( "../global.php" );
include_once( JIEQI_ROOT_PATH."/class/power.php" );
$power_handler =& jieqipowerhandler::getinstance( "JieqiPowerHandler" );
$power_handler->getsavedvars( "system" );
jieqi_checkpower( $jieqiPower['system']['adminuserlog'], $jieqiUsersStatus, $jieqiUsersGroup, false, true );
include_once( JIEQI_ROOT_PATH."/class/logs.php" );
$logs_handler = jieqilogshandler::getinstance( "JieqilogsHandler" );
jieqi_getconfigs( JIEQI_MODULE_NAME, "configs" );
if ( empty( $_REQUEST['page'] ) || !is_numeric( $_REQUEST['page'] ) )
{
		$GLOBALS['_REQUEST']['page'] = 1;
}
include_once( JIEQI_ROOT_PATH."/admin/header.php" );
$criteria = new criteriacompo( );
if ( !empty( $_REQUEST['keyword'] ) )
{
		if ( $_REQUEST['keytype'] == 1 )
		{
				$criteria->add( new criteria( "toname", $_REQUEST['keyword'], "=" ) );
		}
		else
		{
				$criteria->add( new criteria( "fromname", $_REQUEST['keyword'], "=" ) );
		}
}
if ( !empty( $_REQUEST['logtype'] ) )
{
		$jieqiTpl->assign( "logtype", $_REQUEST['logtype'] );
		$criteria->add( new criteria( "logtype", $_REQUEST['logtype'], "=" ) );
}
else
{
		$jieqiTpl->assign( "logtype", "" );
}
if ( !empty( $_REQUEST['loglevel'] ) )
{
		$jieqiTpl->assign( "loglevel", $_REQUEST['loglevel'] );
		$criteria->add( new criteria( "loglevel", $_REQUEST['loglevel'], "=" ) );
}
else
{
		$jieqiTpl->assign( "loglevel", "" );
}
$criteria->setsort( "logid" );
$criteria->setorder( "DESC" );
$criteria->setlimit( $jieqiConfigs['system']['userlogpnum'] );
$criteria->setstart( ( $_REQUEST['page'] - 1 ) * $jieqiConfigs['system']['userlogpnum'] );
$logs_handler->queryobjects( $criteria );
$logrows = array( );
$k = 0;
while ( $v = $logs_handler->getobject( ) )
{
		$logrows[$k]['logtime'] = $v->getvar( "logtime" );
		$logrows[$k]['logid'] = $v->getvar( "logid" );
		$logrows[$k]['siteid'] = $v->getvar( "siteid" );
		$logrows[$k]['logtype'] = $v->getvar( "logtype" );
		$logrows[$k]['loglevel'] = $v->getvar( "loglevel" );
		$logrows[$k]['logtime'] = $v->getvar( "logtime" );
		$logrows[$k]['userid'] = $v->getvar( "userid" );
		$logrows[$k]['username'] = $v->getvar( "username" );
		$logrows[$k]['userip'] = $v->getvar( "userip" );
		$logrows[$k]['targetname'] = $v->getvar( "targetname" );
		$logrows[$k]['targetid'] = $v->getvar( "targetid" );
		$logrows[$k]['targettitle'] = $v->getvar( "targettitle" );
		$logrows[$k]['logurl'] = $v->getvar( "logurl" );
		$logrows[$k]['logcode'] = $v->getvar( "logcode" );
		$logrows[$k]['logtitle'] = $v->getvar( "logtitle" );
		$logrows[$k]['logdata'] = $v->getvar( "logdata" );
		$logrows[$k]['lognote'] = $v->getvar( "lognote" );
		++$k;
}
$jieqiTpl->assign_by_ref( "logrows", $logrows );
jieqi_getconfigs( JIEQI_MODULE_NAME, "lsort", "jieqiLsort" );
if ( !isset( $jieqiLsort ) )
{
		$jieqiLsort = array( );
}
$jieqiTpl->assign_by_ref( "logsort", $jieqiLsort );
include_once( JIEQI_ROOT_PATH."/lib/html/page.php" );
$jumppage = new jieqipage( $logs_handler->getcount( $criteria ), $jieqiConfigs['system']['userlogpnum'], $_REQUEST['page'] );
$jumppage->setlink( "", true, true );
$jieqiTpl->assign( "url_jumppage", $jumppage->whole_bar( ) );
$jieqiTpl->setcaching( 0 );
$jieqiTset['jieqi_contents_template'] = JIEQI_ROOT_PATH."/templates/admin/logs.html";
include_once( JIEQI_ROOT_PATH."/admin/footer.php" );
?>
